package com.neusoft.neuiotms.dcom.model.insurance;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.web.jpa.model.AbstractAuditModel;
import com.neusoft.bizcore.web.jpa.model.Comment;
import com.neusoft.neuiotms.dcom.model.enums.InsuranceTaskStatus;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
@Entity
@Table(name = "neuiot_insurance_summary_task")
@org.hibernate.annotations.Table(appliesTo = "neuiot_insurance_summary_task", comment = "重保服务服务总结任务表")
public class InsuranceSummaryTask extends AbstractAuditModel {

    private static final long serialVersionUID = -321140168892476457L;

    /** 任务编码 */
    @NotBlank(message = "任务编码 ")
    @Length(max = 255, message = "任务编码不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '任务编码 '")
    private String code;

    /** 上报人编码 */
    @Length(max = 255, message = "上报人编码不能超过{max}位")
    @Column(length = 255)
    @Comment("varchar(255) COMMENT '上报人编码'")
    private String reportPersonCode;

    /** 上报人名称 */
    @Length(max = 255, message = "上报人名称不能超过{max}位")
    @Column(length = 255)
    @Comment("varchar(255) COMMENT '上报人名称'")
    private String reportPersonName;

    /** 单位编码 */
    @NotBlank(message = "单位编码不能为空")
    @Length(max = 255, message = "单位编码不能超过{max}位")
    @Column(length = 255)
    @Comment("varchar(255) NOT NULL COMMENT '单位编码'")
    private String unitCode;

    /** 服务开始时间 */
    @Column(nullable = true)
    private Date startTime;

    /** 服务结束时间 */
    @Column(nullable = true)
    private Date endTime;

    /** 重保服务服务总结任务状态 */
    @Enumerated(EnumType.STRING)
    @Column(length = 32, nullable = false)
    @Comment("varchar(32) NOT NULL COMMENT '任务状态'")
    private InsuranceTaskStatus status = InsuranceTaskStatus.notActive;

    /** 服务总结 */
    @Lob
    @Column(columnDefinition = "text")
    @Comment("text COMMENT '服务总结'")
    private String record;

    /** 关联服务总结任务附件表 */
    @OneToMany(mappedBy = "summaryTask", cascade = {CascadeType.ALL })
    @LazyCollection(LazyCollectionOption.FALSE)
    private List<InsuranceSummaryTaskFiles> summaryTaskFiles = new ArrayList<>();

    /** 关联服务登记任务表 */
    @ManyToOne
    private InsuranceRegisterTask registerTask;

}
